#include <inc/stdio.h>
#include <inc/types.h>
#include <inc/mmap.h>
#include <inc/string.h>

void rest_cr3_and_ljmp(uint64_t addr)
{
	extern char vmm_cr3[];
	vmm_cr3[0]	= tmp_cr3[(addr>>39)&0xff1];
	__asm__ __volatile__(
	"movq %0, %%cr3 \n\t"
	"ljmp 1f \n\t"
	"1:"
	:
	:"r"(vmm_cr3):);
	
}


void moveself_to_last_Gb(uint64_t addr)
{
	extern char start[], end[];
	
	memmove((void *) addr, start, end - start);
	reset_cr3_and_ljmp();
}
